package org.nebuloop.photo.organizer.util;

import java.util.concurrent.atomic.AtomicLong;

public class ImageProcessingCounter {
  private final AtomicLong processedImagesCount = new AtomicLong(0);
  private final AtomicLong skippedFileCount = new AtomicLong(0);
  private final ImageProcessingCounter parent;

  public ImageProcessingCounter() {
    this.parent = null;
  }

  public ImageProcessingCounter(ImageProcessingCounter parent) {
    this.parent = parent;
  }

  public long getProcessedImagesCount() {
    return processedImagesCount.get();
  }

  public long getSkippedFileCount() {
    return skippedFileCount.get();
  }

  public long incrementProcessedImagesCount() {
    long result = processedImagesCount.incrementAndGet();
    if (parent != null) {
      parent.incrementProcessedImagesCount();
    }
    return result;
  }

  public long incrementSkippedFileCount() {
    long result = skippedFileCount.incrementAndGet();
    if (parent != null) {
      parent.incrementSkippedFileCount();
    }
    return result;
  }
}
